package com.ikangtai.shecare.common.baseView.recordButtonView;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.View;

import com.ikangtai.shecare.R;

import java.util.Locale;

/**
 * Created by Administrator on 2016/1/20.
 */
public class RecordOptionCopulationButton extends RecordOptionButton implements View.OnClickListener {

    private Context context;
    public static final int RECORD_COPULATION_OPTION_WHITE_BACKGROUND_COLOR = 0;
    public static final int RECORD_COPULATION_OPTION_BLUE_BACKGROUND_COLOR = 1;
    public static final String RecordOptionCopulationButtonType = "COPULATION";

    public RecordOptionCopulationButton(Context context) {
        super(context);
        this.context = context;
    }

    public RecordOptionCopulationButton(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
        backgroundColor = RECORD_COPULATION_OPTION_WHITE_BACKGROUND_COLOR;
        setOnClickListener(this);
        setType(RecordOptionCopulationButtonType);
    }

    @Override
    public void onClick(View v) {
        if (backgroundColor == RECORD_COPULATION_OPTION_WHITE_BACKGROUND_COLOR) {
            if (v.getId() == R.id.record_copulation_knee_chest_position)
                this.setBackground(getResources().getDrawable(R.drawable.record_copulation_knee_chest_button_pressed));
            else if (v.getId() == R.id.record_copulation_supine_position)
                this.setBackground(getResources().getDrawable(R.drawable.record_copulation_supine_button_pressed));
            else
                this.setBackground(getResources().getDrawable(R.drawable.record_copulation_button_pressed));
            this.setTextColor(Color.WHITE);
            backgroundColor = RECORD_COPULATION_OPTION_BLUE_BACKGROUND_COLOR;
        } else {
            if (v.getId() == R.id.record_copulation_knee_chest_position)
                this.setBackground(getResources().getDrawable(R.drawable.record_copulation_knee_chest_button_default));
            else if (v.getId() == R.id.record_copulation_supine_position)
                this.setBackground(getResources().getDrawable(R.drawable.record_copulation_supine_button_default));
            else
                this.setBackground(getResources().getDrawable(R.drawable.record_copulation_button_default));
            this.setTextColor(getResources().getColor(R.color.conpulation_color));
            backgroundColor = RECORD_COPULATION_OPTION_WHITE_BACKGROUND_COLOR;
        }
    }

    @Override
    public void setBackgroundColor(int backGroundColor) {
        switch (Locale.getDefault().getLanguage()) {
            case "zh":
                super.setBackgroundColor(backGroundColor);
                if (backGroundColor == RECORD_COPULATION_OPTION_WHITE_BACKGROUND_COLOR) {
                    if (this.getId() == R.id.record_copulation_knee_chest_position)
                        this.setBackground(getResources().getDrawable(R.drawable.record_copulation_knee_chest_button_default));
                    else if (this.getId() == R.id.record_copulation_supine_position)
                        this.setBackground(getResources().getDrawable(R.drawable.record_copulation_supine_button_default));
                    else
                        this.setBackground(getResources().getDrawable(R.drawable.record_copulation_button_default));
                    this.setTextColor(getResources().getColor(R.color.conpulation_color));
                } else {
                    if (this.getId() == R.id.record_copulation_knee_chest_position)
                        this.setBackground(getResources().getDrawable(R.drawable.record_copulation_knee_chest_button_pressed));
                    else if (this.getId() == R.id.record_copulation_supine_position)
                        this.setBackground(getResources().getDrawable(R.drawable.record_copulation_supine_button_pressed));
                    else
                        this.setBackground(getResources().getDrawable(R.drawable.record_copulation_button_pressed));
                    this.setTextColor(Color.WHITE);
                }
                break;
            default:
                super.setBackgroundColor(backGroundColor);
                if (backGroundColor == RECORD_COPULATION_OPTION_WHITE_BACKGROUND_COLOR) {
                    if (this.getId() == R.id.record_copulation_knee_chest_position)
                        this.setBackground(getResources().getDrawable(R.drawable.record_copulation_knee_chest_button_default_en));
                    else if (this.getId() == R.id.record_copulation_supine_position)
                        this.setBackground(getResources().getDrawable(R.drawable.record_copulation_supine_button_default_en));
                    else
                        this.setBackground(getResources().getDrawable(R.drawable.record_copulation_button_default));
                    this.setTextColor(getResources().getColor(R.color.conpulation_color));
                } else {
                    if (this.getId() == R.id.record_copulation_knee_chest_position)
                        this.setBackground(getResources().getDrawable(R.drawable.record_copulation_knee_chest_button_pressed_en));
                    else if (this.getId() == R.id.record_copulation_supine_position)
                        this.setBackground(getResources().getDrawable(R.drawable.record_copulation_supine_button_pressed_en));
                    else
                        this.setBackground(getResources().getDrawable(R.drawable.record_copulation_button_pressed));
                    this.setTextColor(Color.WHITE);
                }
        }

    }

}
